home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeed.gsfc.nasa.gov!usenet
- From: tycho <vonrosen@nssdca.gsfc.nasa.gov>
- Newsgroups: comp.lang.c++
- Subject: sprintf() in C++
- Date: 9 Apr 1996 22:13:24 GMT
- Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA
- Message-ID: <4kene4$nkb@post.gsfc.nasa.gov>
- NNTP-Posting-Host: tycho.gsfc.nasa.gov
-
- I could use some help with regard to sprintf() in C++. It seems that
- cout and cin were invented to avoid printf() and scanf() because the
- latter have variable argument lists and hence can't be checked against
- function prototypes. But is there any corresponding C++ approach to
- sprintf() and sscanf()? When I look at various string class functions
- I don't see what to use instead of sprintf() and sscanf(). But when I
- look at my C code, I'm using sprintf() and sscanf() all the time. It
- seems very clumsy to cast a string object to a character array, use
- sprintf() to write to it and then convert the result back to a string
- object. And, of course, using sprintf() means that the compiler can't
- check against a prototype. So what am I missing? I have examined a
- number of standard texts and they don't seem to ever go into this when
- talking about strings. K&R discuss sprintf() and sscanf() under the
- heading of "In-memory Format Conversion", but these functions do much
- more than that.
-
- As a newcomer to C++ I will appreciate any assistance you can give.
-
- Thanks,
-
- Tycho von Rosenvinge
-
-